Skip to content

Conversation

@Hunaid2000
Copy link
Contributor

@Hunaid2000 Hunaid2000 commented Dec 11, 2025

Fix 26.

The issue was incorrect order of returned tuples and postgres was applying filter on wrong column, resulting in no rows.
Note: The fix idea is taken from redis_fdw example in supabase/wrappers repository.

etcd_fdw=# select value from test where key = 'key2';
 value
--------
 value2
(1 row)

etcd_fdw=# select value from test where key >= 'key2';
 value
--------
 value2
 value3
 value4
 value5
 value6
(5 rows)

etcd_fdw=# select value, key from test where key = 'key2';
 value  | key
--------+------
 value2 | key2
(1 row)

Example of UPDATE operation:

-- some inserts for example
INSERT INTO test(key, value) VALUES
('/gather/84', '{"foo":"bar"}'),
('/gather/85', '{"foo":"baz"}');
INSERT 0 2

-- Update referencing key and value
UPDATE test
SET key=key, value = value::jsonb || '{"gather_status":"active"}'::jsonb
WHERE key = '/gather/84';
UPDATE 1

-- Update referencing only value
UPDATE test
SET value = value::jsonb || '{"gather_status":"active"}'::jsonb
WHERE key = '/gather/84';
UPDATE 1

select * from test where key like '/gather%';
    key     |                   value
------------+-------------------------------------------
 /gather/84 | {"foo": "bar", "gather_status": "active"}
 /gather/85 | {"foo":"baz"}
(2 rows)

Example of JOIN operation:

-- just a test local table
CREATE TABLE local_gather(id int8);
INSERT INTO local_gather VALUES (84), (85);
CREATE TABLE
INSERT 0 2

SELECT
    g.*,
    sh.value::jsonb ->> 'gather_status'
FROM local_gather g
LEFT JOIN (SELECT key, value FROM test) sh
    ON sh.key = '/gather/' || g.id;
 id | ?column?
----+----------
 84 | active
 85 |
(2 rows)

@pashagolub
Copy link
Contributor

thanks! I'm on it!

Copy link
Contributor

@pashagolub pashagolub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM!

@pashagolub pashagolub merged commit c332920 into cybertec-postgresql:main Dec 11, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Not including the key in the SELECT results in weird behavior

2 participants